package org.ns.learn.rpc.codec;

public class RpcRequest {

    String requestId;

    String beanName; // BEAN Name

    String methodName;

    ParameterType[] parameterTypes;

    Object[] parameters;

    public RpcRequest() {

    }

    public RpcRequest(String beanName, String methodName, ParameterType parameterType, Object parameter) {
        this(beanName, methodName, new ParameterType[]{parameterType}, new Object[]{parameter});
    }
    public RpcRequest(String beanName, String methodName, ParameterType[] parameterTypes, Object[] parameters) {
        this.beanName = beanName;
        this.methodName = methodName;
        this.parameterTypes = parameterTypes;
        this.parameters = parameters;
    }

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public String getBeanName() {
        return beanName;
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    public String getMethodName() {
        return methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public ParameterType[] getParameterTypes() {
        return parameterTypes;
    }

    public Class<?>[] toTypes() {
        if (parameterTypes == null) {
            return new Class[0];
        }
        Class<?>[] classes = new Class<?>[parameterTypes.length];
        for (int i = 0; i < parameterTypes.length; i++) {
            classes[i] = parameterTypes[i].getParameterType();
        }
        return classes;
    }

    public void setParameterTypes(ParameterType[] parameterTypes) {
        this.parameterTypes = parameterTypes;
    }

    public Object[] getParameters() {
        return parameters;
    }

    public void setParameters(Object[] parameters) {
        this.parameters = parameters;
    }

    public static void main(String[] args){
        class B {}
        class A {
            Object[] value;
            Class<?> types[];

            public void setValue(Object[] value) {
            this.value = value;
            }

            public Object[] getValue() {
            return value;
            }

            public void setTypes(Class<?> types[]) {
                this.types = types;
            }

            public Class<?>[] getTypes() {
                return types;
            }
        }

    }
}
